Skip to content

add fields to configure plugin conda executable and env paths#2654

Open
emlys wants to merge 17 commits into
natcap:mainfrom
emlys:feature/2645
Open

add fields to configure plugin conda executable and env paths#2654
emlys wants to merge 17 commits into
natcap:mainfrom
emlys:feature/2645

Conversation

@emlys

@emlys emlys commented Jul 8, 2026

Copy link
Copy Markdown
Member

Description

Fixes #2645, fixes #2646
Add an interface in the "Manage Plugins" modal to change the configured conda executable and plugin environment paths (equivalent to the micromamba and plugins.<plugin ID>.env properties in config.json).

I added defaultMicromamba and plugins.<plugin ID>.defaultEnv properties to the config.json to track the original values so that they can be reset if needed.

Needed to mock the plugin data returned from GET_SETTING in a couple more tests.

Checklist

  • Updated HISTORY.rst and link to any relevant issue (if these changes are user-facing)
  • Updated the user's guide (if needed)
  • Tested the Workbench UI (if relevant)

fs.writeFileSync(baseEnvYMLPath, baseEnvYMLContents);
await spawnWithLogging(micromamba, [
'create', '--yes', '--prefix', `"${baseEnvPrefix}"`,
'env', 'create', '--yes', '--prefix', `"${baseEnvPrefix}"`,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that "env create" rather than just "create" is necessary for compatibility with conda.

@emlys
emlys requested a review from emilyanndavis July 15, 2026 19:54
@emlys
emlys marked this pull request as ready for review July 15, 2026 19:54

@emilyanndavis emilyanndavis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @emlys. I found a bug in the browse button behavior, and I left some other (minor) suggestions as well.

Beyond those code-specific comments, a couple of other things came to mind when I was trying out the "Configure conda executable" UI:

  • It's not immediately clear that the path to the executable is actually the path to the directory that contains the executable, not the full path including the name of the executable (at least I'm assuming that's the case, since I was able to select only folders, not actual executable files). I wonder if there's a way to elegantly include this detail in the description, and/or add an example? I expect many people who use this option will use the browse button and figure it out from context (like I did), but I wonder what would happen if someone directly entered the full path including the name of the executable.
  • The default value, micromamba, could be misleading, since it's not obviously a path. I can imagine someone entering simply conda and ending up disappointed. Is the default value in fact a path? If so, is there a way to make that more obvious (such as expanding it to its full path)? If not, could we display the path? Or perhaps expand the display text to something like InVEST-bundled micromamba (default) so it's abundantly clear it's not merely the name of the package manager?

Comment thread workbench/src/renderer/components/PluginModal/index.jsx Outdated
Comment thread workbench/src/renderer/components/PluginModal/index.jsx Outdated
<Button
aria-label="browse for conda executable"
className="browse-button ms-1 me-1"
id="browse-conda-button"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for an id here unless you are referencing it elsewhere (and it doesn't look like you are). If you want a handle for testing, it can be convenient to add a data- attribute that is clearly there for testing purposes. (For example, data-testid, which we use in a couple of components, automatically works with the DOM Testing Library's findByTestId query.)

Comment thread workbench/src/renderer/components/PluginModal/index.jsx Outdated
Comment thread workbench/src/renderer/components/PluginModal/index.jsx Outdated
<Button
aria-label="browse for env"
className="browse-button ms-1 me-2"
id="browse-env-button"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for an id here either.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…unless that id ends up being referenced by the click handler, in which case, make sure each instance of this button has a unique id (e.g., including the relevant plugin ID).

className="browse-button ms-1 me-2"
id="browse-env-button"
variant="outline-dark"
onClick={selectDirectory}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out why the browse buttons didn't seem to be working for me, until I looked more closely at the code. Every browse button in the modal is calling selectDirectory on click… and selectDirectory always populates the path field in the 'Add a plugin' form! So when I use a browse button to choose a conda path or a plugin env, my selection lands in the wrong form. You may want to write separate functions, or it might make sense to refactor selectDirectory to take another argument or perhaps parse data attached to the event.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some automated tests might be helpful here, too! 😃

emlys and others added 4 commits July 17, 2026 09:01
Co-authored-by: Emily Davis <emilyanndavis@gmail.com>
Co-authored-by: Emily Davis <emilyanndavis@gmail.com>
Co-authored-by: Emily Davis <emilyanndavis@gmail.com>
Co-authored-by: Emily Davis <emilyanndavis@gmail.com>
@emlys

emlys commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

Clearly I forgot to try out the file chooser dialog for the conda executable! It is supposed to select a file, not a directory. When the binaries are built, the default executable will look like an actual path, something like /Users/emily/Applications/InVEST Workbench.app/Contents/Resources/micromamba. In dev mode, it defaults to micromamba because it assumes you have micromamba installed and on the PATH.

I don't know that the file chooser is very useful here, I imagine the typical use would be replacing the micromamba path with conda or mamba which the user has already installed, so providing the full path is unnecessary. I just figured I'd include the file chooser for consistency with the other form fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workbench option to set a user-defined conda env for a plugin Workbench option to use a user-provided conda installation

2 participants